package :PACKAGE_NAME:.:ARTIFACT_ID:;

import flash.display.Graphics;
import flash.display.MovieClip;

import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;

/**
 *
 * <p>
 * App it up, yo!
 * </p>
 *
 */
class App {

	var clip:MovieClip;

	public function new( ?clip:MovieClip ) {
		this.clip = if ( null == clip ) {
			flash.Lib.current;
		} else {
			clip;
		}

		this.addEventListeners();
	}

	public function addEventListeners() {
		this.clip.addEventListener( Event.ENTER_FRAME, enter_frame );
		this.clip.stage.addEventListener( MouseEvent.MOUSE_DOWN, mouse_down );
		this.clip.stage.addEventListener( MouseEvent.MOUSE_UP, mouse_up );
		this.clip.stage.addEventListener( KeyboardEvent.KEY_DOWN , key_down );
	}

	public function mouse_down( mouseEvent : MouseEvent ) {
		trace( mouseEvent );
	}

	public function mouse_up( mouseEvent : MouseEvent ) {
		trace( mouseEvent );
	}

	public function key_down( keyboardEvent : KeyboardEvent ) {
		trace( keyboardEvent );
	}

	public function enter_frame( _ ) {
		this.draw( this.clip.graphics );
	}

	public function draw( g:Graphics ) {
		g.clear();
		g.lineStyle( 2, 0xFF0000 );
		g.moveTo( 0, 0 );
		g.lineTo( this.clip.stage.stageWidth, this.clip.stage.stageHeight );
	}
}
